#ifndef __BUOLA_GUI_X11_CGLX_H__
#define __BUOLA_GUI_X11_CGLX_H__

#include <buola/gui/x11/auto.h>

#include <buola/gl.h>

#define GLX_GLXEXT_PROTOTYPES
#include <GL/glx.h>

#define GLX_SERVERVERSION(maj,min)  (((((unsigned int)maj)&0xffff)<<16)|(((unsigned int)min)&0xffff))

namespace buola { namespace gui { namespace x11 {

class CGLX
{
public:
    static const int MAX_DEPTH=32;

    struct SFBConfig
    {
        GLXFBConfig mConfig;
        bool mYInverted;
        bool mMipMap;
        int mTextureFormat;
    };

private:
    static void InitFBConfigs();

public:
    static unsigned int GetVersion();
    static int GetConfig(XVisualInfo *pInfo,int pParam);
    static bool HasGLXExtension(const std::string&);
    static bool HasGLExtension(const std::string&);
    static SFBConfig *GetConfigForDepth(int pDepth)
    {
        if(!mFBConfigsInit) InitFBConfigs();

        return &mFBConfigs[pDepth];
    }

private:
    static std::string mGLXExtensions;
    static std::string mGLExtensions;
    static SFBConfig mFBConfigs[MAX_DEPTH+1];
    static bool mFBConfigsInit;
};

/*namespace x11*/ } /*namespace gui*/ } /*namespace buola*/ }

#endif
